;
; ------------------------------------------------------------
;
;   PureBasic - Palette example file
;
;    (c) 2004 - Fantaisie Software
;
; ------------------------------------------------------------
;
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitPalette() = 0
  MessageRequester("Error", "Can't open DirectX 7 or later", 0)
  End
EndIf

If OpenScreen(640, 480, 8, "PureBasic - Palette Example")
  LoadSprite(0, "Data\AlphaChannel.bmp", 0)
  
  ; Build 256 precalculated palette to do a nice cycling effect !
  ;
  For Palette = 0 To 255
    CreatePalette(Palette)
      For Index = 1 To 255  ; Let the first color always Black
        Color = Index+Palette
        If Color > 255
          Color - 256
        EndIf
        
        SetPaletteColor(Palette, Index, Color << 8)
      Next
  Next
  
  Palette = 0
  Repeat
    FlipBuffers()                                 ; Flip for DoubleBuffering
    ClearScreen(RGB(0, 0, 0))
    
    DisplayPalette(Palette)
    DisplaySprite(0, 100, 100)
    
    Palette+1
    If Palette > 255 : Palette = 0 : EndIf
      
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape)
EndIf

End  
 